﻿using System.Collections.Generic;
using System.Linq;

namespace Pap.Data
{
    /// <summary>
    /// 
    /// </summary>
    public partial class Customer : ICustomer
    {
        #region ICustomer Members

        /// <summary>
        /// Gets the phones.
        /// </summary>
        public IEnumerable<IPhone> Phones
        {
            get
            {
                return this.CustomerPhones.OfType<IPhone>();
            }
        }

        /// <summary>
        /// Gets or sets the gender.
        /// </summary>
        /// <value>
        /// The gender.
        /// </value>
        CustomerGender ICustomer.Gender
        {
            get
            {
                return (CustomerGender)this.Gender;
            }
            set
            {
                this.Gender = (byte)value;
            }
        }

        /// <summary>
        /// Gets or sets the educational level.
        /// </summary>
        /// <value>
        /// The educational level.
        /// </value>
        ILookUpEntity ICustomer.EducationalLevel
        {
            get
            {
                return this.EducationalLevel;
            }
            set
            {
                this.EducationalLevel = (EducationalLevel)value;
            }
        }

        /// <summary>
        /// Gets the issue place obj.
        /// </summary>
        IIssuePlace ICustomer.IssuePlaceObj
        {
            get
            {
                return this.IssuePlace;
            }
        }

        /// <summary>
        /// Gets or sets the social statuse.
        /// </summary>
        /// <value>
        /// The social statuse.
        /// </value>
        ILookUpEntity ICustomer.SocialStatuse
        {
            get
            {
                return this.SocialStatuse;
            }
            set
            {
                this.SocialStatuse = (SocialStatuse)value;
            }
        }

        /// <summary>
        /// Gets the birth location obj.
        /// </summary>
        public ICenter BirthLocationObj
        {
            get
            {

                return this.Center;
            }
        }

        /// <summary>
        /// Gets the loans.
        /// </summary>
        public IEnumerable<ICustomerLoan> Loans
        {
            get
            {
                return this.CustomerLoans.OfType<ICustomerLoan>();
            }
        }

        /// <summary>
        /// Adds the phone.
        /// </summary>
        /// <param name="phone">The phone.</param>
        public void AddPhone(IPhone phone)
        {
            this.CustomerPhones.Add(phone as CustomerPhone);
        }

        #endregion

        /// <summary>
        /// Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            return this.CustomerName;
        }
    }
}
